import {a_tank_actionproperty, tank_actions} from "../commdata";
import {tsxRegex} from "ts-loader/dist/constants";

export class Basebio {
    name:string="";
    fun:string="r";
    x:number=0;
    y:number=0;
    team:number=0;
    demage:number=30;
    actionimg:any;
    fireimag:any;
    isfire:boolean=false;
    fireindex:number=0;
    firecount:number=3;
    actionindex:number=0;
    actioncount:number=0;
    actrons: any = [];
    currantactions:any=[];
    live: number = 100;
    livelimit: number = 100;
    speed:number=0;
    ratewidth:number=0;
    rateheight:number=0;
    shootrange:number=100;
    searchrange:number=200;
    //sdadio=new Audio();
    deadfinish:boolean=false;
    isstart:boolean=false;
    killcount:number=0;
    enable:boolean=false;
    issumflag:boolean=false;  //是否参与计数

    //是否检测到目标
    isSearchRange=(enemy:Basebio):boolean=>{
        if(enemy.x>this.x+this.ratewidth && enemy.x<this.x+this.ratewidth+this.searchrange){
            if(enemy.y>this.y+this.rateheight && enemy.y<this.y+this.rateheight+this.searchrange)
            {
                return true;
            }
            else if(enemy.y<this.y && enemy.y>this.y-this.searchrange)
            {
                return true;
            }
        }
        else if(enemy.x<this.x && enemy.y>this.x-this.searchrange)
        {
            if(enemy.y>this.y+this.rateheight && enemy.y<this.y+this.rateheight+this.searchrange)
            {
                return true;
            }
            else if(enemy.y<this.y && enemy.y>this.y-this.searchrange)
            {
                return true;
            }
        }
        return false;
    }

    //是否可攻击范围
    isAtacctRange=(enemy:Basebio):boolean=>{
        if(enemy.x>this.x-this.shootrange && enemy.x<this.x+this.ratewidth+this.shootrange){
            if(enemy.y>this.y-this.shootrange && enemy.y<this.y+this.rateheight+this.shootrange){
                return  true;
            }
        }
        return false;
    }

    //绕过障碍物
    runblocks=()=>{

    }
}